const paths = require('./paths');
const HtmlWebpackPlugin=require("html-webpack-plugin");
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const friendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const progress=require("progress-bar-webpack-plugin")
module.exports = {
    mode:"development",
    devtool: 'inline-source-map',
    entry: {
        app:paths.app
    },
    output: {
        path:paths.output,
        filename: '[name].bundle.js',
    },
    module: {
        rules: [
            {
                test: /\.(js|mjs|jsx|ts|tsx)$/,
                exclude: /node_modules/,
                use: {
                    loader: 'babel-loader',
                },
            },
            {
                test: /\.css$/,
                use: [
                    'style-loader',
                    "css-loader"
                ]
            },
            {
                test: /\.less$/,
                exclude: /node_modules/,
                use: [
                    'style-loader',
                    {
                        loader: "css-loader",
                        options: {
                            modules: true
                        }
                    },
                    "less-loader"
                ]
            }
        ],
    },
    devServer: {
        historyApiFallback: true,
        contentBase:paths.output,
        open:true,
        hot: true,
        quiet: true,
        port: 8082,
    },
    plugins: [
        new HtmlWebpackPlugin({
            title: "cc-edu",
            template:paths.public,
            filename: 'index.html'
        }),
        new CleanWebpackPlugin(),
        new friendlyErrorsWebpackPlugin(),
        new progress()
    ],
    resolve: {
        extensions: [".js", ".jsx", ".json",".ts",".tsx"],
        modules: ["node_modules"]
    },
}